CC		= x86_64-w64-mingw32-gcc
LINK		= x86_64-w64-mingw32-ld
CC_OPTS		= -fno-stack-protector -fpic -fshort-wchar -mno-red-zone
LINK_OPTS	= -e efi_main

ALL_BIN		= hello.efi videomode.efi mmap.efi load.efi
ALL_INSTALL	= install_hello install_videomode install_mmap install_load
INSTALL_DIR	= /boot/efi/EFI/efi_apps

#---------------------------------------------------
all: $(ALL_BIN)

#---------------------------------------------------
install: $(ALL_INSTALL)

install_%: %.efi
	sudo cp -f $< $(INSTALL_DIR)

#---------------------------------------------------
%.efi: %.o
	$(LINK) -o $@ $< --subsystem 10 $(LINK_OPTS)

%.o: %.c
	$(CC) -c -o $@ $< -I/usr/include/efi $(CC_OPTS)

#---------------------------------------------------
prepare:
	sudo mkdir /boot/efi/EFI/efi_apps

clean:
	rm -f *.o
	rm -f *.efi
